Chart B
## The distribution of order main hour of the day for each day in the weekend for Pink Lady Apples
pink = instacart %>%
filter(product_name %in% "Pink Lady Apples") %>%
mutate(order_dow=as.factor(order_dow)) %>%
group_by(order_dow) %>%
mutate(name = "Pink Lady Apples")%>%
plot_ly(y = ~order_hour_of_day, x = ~order_dow, color=~order_dow, type = "box")
pink
Chart C
## Comparison between Coffee Ice Crean and Pink Lady Apples in mean order time for each day of the week
pink_mean = instacart %>%
filter(product_name %in% "Pink Lady Apples") %>%
group_by(order_dow) %>%
summarise(mean_hour = mean(order_hour_of_day) ) %>%
mutate(name = "Pink Lady Apples")
coffee_mean = instacart %>%
filter(product_name %in% "Coffee Ice Cream") %>%
group_by(order_dow) %>%
summarise(mean_hour = mean(order_hour_of_day) )%>%
mutate(name = "Coffee Ice Cream")
com=full_join(pink_mean,coffee_mean) %>%
mutate(order_dow=as.factor(order_dow)) %>%
plot_ly(
x = ~order_dow, y = ~mean_hour, color=~name, type = "scatter", mode = "line",alpha = 0.5)
## Joining, by = c("order_dow", "mean_hour", "name")
com